package com.woniuxy.mapper.impl;

import java.sql.*;

/**
 * @author 作者
 * @create 2025-08-11 9:37
 */
public class JdbcUtil {

    public static Connection getConnection() throws ClassNotFoundException, SQLException {
        String className = "com.mysql.cj.jdbc.Driver";
        String url = "jdbc:mysql:///db2";
        String user = "root";
        String password = "123";
        Class.forName(className);
        return DriverManager.getConnection(url, user, password);
    }

    public static void close(Connection conn, PreparedStatement ps, ResultSet rs) throws SQLException {
        if (rs != null) {
            rs.close();
        }
        if (ps != null) {
            ps.close();
        }
        if (conn != null) {
            conn.close();
        }
    }

}
